package com.anlu.concurrent.ch4;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author anlu
 * @date 2021/9/8 10:54
 */
public class LockDemo {
    private Lock lock = new ReentrantLock();
    private int count;

    public void increment(){
        lock.lock();
        try{
            count++;
        }finally {
            lock.unlock();
        }
    }

    public synchronized void incr2(){
        count++;
        incr2();
    }
    public synchronized void test3() {
        incr2();
    }
}
